package poj1028;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.Stack;

/*
poj1028,1p69
输入：
VISIT http://acm.ashland.edu/
VISIT http://acm.baylor.edu/acmicpc/
BACK
BACK
BACK
FORWARD
VISIT http://www.ibm.com/
BACK
BACK
FORWARD
FORWARD
FORWARD
QUIT
输出：
http://acm.ashland.edu/
http://acm.baylor.edu/acmicpc/
http://acm.ashland.edu/
http://www.acm.org/
Ignored
http://acm.ashland.edu/
http://www.ibm.com/
http://acm.ashland.edu/
http://www.acm.org/
http://acm.ashland.edu/
http://www.ibm.com/
Ignored
 */
public class Main {

	public static void main(String[] args) throws IOException {
		Stack<String> backward = new Stack<String>();
		Stack<String> forward = new Stack<String>();
		
		//Scanner sc = new Scanner(System.in);
		
		//输入优化
		BufferedReader read = new BufferedReader(new InputStreamReader(System.in));
		//String[] line = sc.nextLine().split(" ");
		
		//逐行读取,按空格拆分
		String[] line = read.readLine().split(" ");
		String cur = "http://www.acm.org/";
		
		
		//StringBuilder优化输出
		StringBuilder sb = new StringBuilder();
		
		while(!line[0].equals("QUIT")) {
			if(line[0].equals("VISIT")) {
				//当前页面进入后向栈
				backward.push(cur);
				cur = line[1];
				//System.out.println(cur);
				sb.append(cur);
				sb.append("\n");
				//清空前向栈
				forward.clear();
			}else if(line[0].equals("BACK")) {
				if(backward.isEmpty()) {
					//System.out.println("Ignored");
					sb.append("Ignored");
					sb.append("\n");
				} else {
					//当前页面进入前向栈
					forward.push(cur);
					//取后向栈为当前页面
					cur = backward.pop();
					//System.out.println(cur);
					sb.append(cur);
					sb.append("\n");
				}
			}else {
				//FORWARD的情况
				if(forward.isEmpty()){
					//System.out.println("Ignored");
					sb.append("Ignored");
					sb.append("\n");
				} else {
					//当前页面进入后向栈
					backward.push(cur);
					//取前向栈为当前页面
					cur = forward.pop();
					//System.out.println(cur);
					sb.append(cur);
					sb.append("\n");
				}
			}
			
			//line = sc.nextLine().split(" ");
			//逐行读取,按空格拆分
			line = read.readLine().split(" ");
		}
		
		System.out.println(sb.toString());
	}

}
